home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------
- TOGLCASE.C -- Extension DLL for E! - version 2.0
-
- To compile: nmake /f toglcase.mak
-
- Once compiled, copy TOGLCASE.EWD to your USER directory.
-
- TOGLCASE can be used to toggle the case of each character of the current
- word. For example, bADcASE would be converted to BadCase. Since we use
- EWSetLineAt() and a line buffer to change the line instead of directly
- modifying the original line, this action can be undone.
-
- To use this DLL simply load it from the user menu or add its name to the
- list of autoloaded Extension DLLs by using the Autoload dialog box from
- the User Menu of EW. That's all.
-
- This Extension DLL uses no hook. It merely uses some API functions to
- select the word at the cursor position.
-
- You can assign this extension to a keystroke. See the documentation for
- a description of how to assign DLL execution to a keystroke.
- ------------------------------------------------*/
-
- #include <windows.h>
- #include "ewapi2.h"
-
- int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
- LPSTR lpszCmdLine)
- {
- if (wHeapSize > 0)
- UnlockData (0) ;
- return 1 ;
- }
-
- char far LineBuffer[256];
-
- int FAR PASCAL EWExecute(unsigned int RoutineId)
- {
- long WordBoundaries;
- long CurrentLine;
- int i;
-
- /* Get the first and last character of the current word */
- WordBoundaries = EWGetCurWord();
- if (WordBoundaries != -1L) {
- /* Get the current line */
- CurrentLine = EWGetCaretPosY();
- /* Change case of each character */
- lstrcpy(LineBuffer, EWGetLineAt(CurrentLine));
- for (i = (int) LOWORD(WordBoundaries); i < (int) HIWORD(WordBoundaries); i++)
- {
- if (IsCharUpper(LineBuffer[i]))
- AnsiLowerBuff(LineBuffer + i, 1);
- else
- AnsiUpperBuff(LineBuffer + i, 1);
- }
- EWSetLineAt(LineBuffer, CurrentLine);
- EWSetModified();
- return(0);
- }
- else
- return(ewerr_EXTFAILED);
- }
-